const mongoose = require("mongoose");
const Schema = mongoose.Schema;

const companyMaterialSchema = new mongoose.Schema({
  //类别
  category: {
    type: String,
    required: [true, "you must tell us your  material category"],
  },
  //型号
  type: {
    type: String,
    required: [true, "you must tell us your material type"],
  },
  //密度（单位默认为g/cm3)
  density: {
    type: Number,
    required: [true, "you must tell us your material density"],
    min: 0,
  },
  //材料所属公司Id
  company_id: {
    type: Schema.Types.ObjectId,
    ref: "Company",
    required: [true, "you must tell us your company_id of material"],
  },
  //原料费
  m_cost: {
    type: Number,
    required: [true, "you must tell us your material cost"],
    min: 0,
  },
  //加工方式
  processMode: {
    type: String,
    enum: ["0", "1"],
    required: [true, "you must tell us your baseplate processingMode"],
  },
  //0表示按重量计算 1表示按面积计算  元/kg  元/m2
});

const CompanyMaterial = mongoose.model(
  "CompanyMaterial",
  companyMaterialSchema
);
module.exports = CompanyMaterial;
